<template>
  <div>
    <span>{{user.username}}</span>&ensp;&ensp;
    <el-button @click="logout()">退出</el-button>
  </div>
  <!--<img :src="user.avaurl">在线加载图片-->
</template>

<script>
export default {
  name: "Header",
  methods:{
    logout()
    {
      localStorage.removeItem("user");
      this.$router.push("/login");
    }
  },
  data(){
    return{
      user: localStorage.getItem("user")?JSON.parse(localStorage.getItem("user")):{}
    }
  }
}
</script>

<style scoped>

</style>